/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.portlet.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.portlet.model.nguyenlieu;
import com.portlet.model.nguyenlieuModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the nguyenlieu service. Represents a row in the &quot;congty_nguyenlieu&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.portlet.model.nguyenlieuModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link nguyenlieuImpl}.
 * </p>
 *
 * @author Thi
 * @see nguyenlieuImpl
 * @see com.portlet.model.nguyenlieu
 * @see com.portlet.model.nguyenlieuModel
 * @generated
 */
public class nguyenlieuModelImpl extends BaseModelImpl<nguyenlieu>
	implements nguyenlieuModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a nguyenlieu model instance should use the {@link com.portlet.model.nguyenlieu} interface instead.
	 */
	public static final String TABLE_NAME = "congty_nguyenlieu";
	public static final Object[][] TABLE_COLUMNS = {
			{ "maNguyenLieu", Types.VARCHAR },
			{ "tenNguyenLieu", Types.VARCHAR },
			{ "ghiChu", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table congty_nguyenlieu (maNguyenLieu VARCHAR(75) not null primary key,tenNguyenLieu VARCHAR(75) null,ghiChu VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table congty_nguyenlieu";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.portlet.model.nguyenlieu"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.portlet.model.nguyenlieu"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.portlet.model.nguyenlieu"));

	public nguyenlieuModelImpl() {
	}

	public String getPrimaryKey() {
		return _maNguyenLieu;
	}

	public void setPrimaryKey(String primaryKey) {
		setMaNguyenLieu(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _maNguyenLieu;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return nguyenlieu.class;
	}

	public String getModelClassName() {
		return nguyenlieu.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("maNguyenLieu", getMaNguyenLieu());
		attributes.put("tenNguyenLieu", getTenNguyenLieu());
		attributes.put("ghiChu", getGhiChu());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		String maNguyenLieu = (String)attributes.get("maNguyenLieu");

		if (maNguyenLieu != null) {
			setMaNguyenLieu(maNguyenLieu);
		}

		String tenNguyenLieu = (String)attributes.get("tenNguyenLieu");

		if (tenNguyenLieu != null) {
			setTenNguyenLieu(tenNguyenLieu);
		}

		String ghiChu = (String)attributes.get("ghiChu");

		if (ghiChu != null) {
			setGhiChu(ghiChu);
		}
	}

	public String getMaNguyenLieu() {
		if (_maNguyenLieu == null) {
			return StringPool.BLANK;
		}
		else {
			return _maNguyenLieu;
		}
	}

	public void setMaNguyenLieu(String maNguyenLieu) {
		_maNguyenLieu = maNguyenLieu;
	}

	public String getTenNguyenLieu() {
		if (_tenNguyenLieu == null) {
			return StringPool.BLANK;
		}
		else {
			return _tenNguyenLieu;
		}
	}

	public void setTenNguyenLieu(String tenNguyenLieu) {
		_tenNguyenLieu = tenNguyenLieu;
	}

	public String getGhiChu() {
		if (_ghiChu == null) {
			return StringPool.BLANK;
		}
		else {
			return _ghiChu;
		}
	}

	public void setGhiChu(String ghiChu) {
		_ghiChu = ghiChu;
	}

	@Override
	public nguyenlieu toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (nguyenlieu)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	public nguyenlieu toUnescapedModel() {
		return (nguyenlieu)this;
	}

	@Override
	public Object clone() {
		nguyenlieuImpl nguyenlieuImpl = new nguyenlieuImpl();

		nguyenlieuImpl.setMaNguyenLieu(getMaNguyenLieu());
		nguyenlieuImpl.setTenNguyenLieu(getTenNguyenLieu());
		nguyenlieuImpl.setGhiChu(getGhiChu());

		nguyenlieuImpl.resetOriginalValues();

		return nguyenlieuImpl;
	}

	public int compareTo(nguyenlieu nguyenlieu) {
		String primaryKey = nguyenlieu.getPrimaryKey();

		return getPrimaryKey().compareTo(primaryKey);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof nguyenlieu)) {
			return false;
		}

		nguyenlieu nguyenlieu = (nguyenlieu)obj;

		String primaryKey = nguyenlieu.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<nguyenlieu> toCacheModel() {
		nguyenlieuCacheModel nguyenlieuCacheModel = new nguyenlieuCacheModel();

		nguyenlieuCacheModel.maNguyenLieu = getMaNguyenLieu();

		String maNguyenLieu = nguyenlieuCacheModel.maNguyenLieu;

		if ((maNguyenLieu != null) && (maNguyenLieu.length() == 0)) {
			nguyenlieuCacheModel.maNguyenLieu = null;
		}

		nguyenlieuCacheModel.tenNguyenLieu = getTenNguyenLieu();

		String tenNguyenLieu = nguyenlieuCacheModel.tenNguyenLieu;

		if ((tenNguyenLieu != null) && (tenNguyenLieu.length() == 0)) {
			nguyenlieuCacheModel.tenNguyenLieu = null;
		}

		nguyenlieuCacheModel.ghiChu = getGhiChu();

		String ghiChu = nguyenlieuCacheModel.ghiChu;

		if ((ghiChu != null) && (ghiChu.length() == 0)) {
			nguyenlieuCacheModel.ghiChu = null;
		}

		return nguyenlieuCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{maNguyenLieu=");
		sb.append(getMaNguyenLieu());
		sb.append(", tenNguyenLieu=");
		sb.append(getTenNguyenLieu());
		sb.append(", ghiChu=");
		sb.append(getGhiChu());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("com.portlet.model.nguyenlieu");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>maNguyenLieu</column-name><column-value><![CDATA[");
		sb.append(getMaNguyenLieu());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>tenNguyenLieu</column-name><column-value><![CDATA[");
		sb.append(getTenNguyenLieu());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>ghiChu</column-name><column-value><![CDATA[");
		sb.append(getGhiChu());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = nguyenlieu.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			nguyenlieu.class
		};
	private String _maNguyenLieu;
	private String _tenNguyenLieu;
	private String _ghiChu;
	private nguyenlieu _escapedModel;
}